﻿using UnityEngine;
using DG.Tweening;

namespace UFrame
{
    public class DOTweenCommon
    {
        public void JumpScale(Transform rt)
        {
#if DOTween
            var p = rt.position;
            p.y += 1;
            var p2 = rt.localPosition;
            p2.y += 10;

            var s = DOTween.Sequence();
            s.Append(rt.DOLocalMoveY(p2.y + 5.0f, 0.5f));
            s.Insert(0,rt.DOScale(new Vector3(1.5f, 1.5f, 1), 0.5f).SetEase(Ease.InOutBounce));
            s.SetLoops(2,LoopType.Yoyo);
            s.onComplete = () =>
            {
                rt.transform.localScale = Vector3.one;
            };
#endif
        }

        /// <summary>
        /// 常用动画
        /// </summary>
        /// <param name="trans"></param>
        public static void ScaleAnima(Transform trans)
        {
#if DOTween
          trans.DOScale(new Vector3(0.95f, 0.95f, 0.95f),1.5f).SetLoops(-1, LoopType.Yoyo).SetEase(Ease.Linear);
#endif
        }
    }
}